package com.campus.customer.controller;

import com.campus.common.bean.common.PageQueryParam;
import com.campus.common.bean.common.Pagination;
import com.campus.common.bean.common.Resp;
import com.campus.customer.service.CanteenService;
import com.campus.customer.vo.CanteenVo;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 食堂表 前端控制器
 * </p>
 *
 * @author ZhaoYuJie
 * @since 2025-04-02
 */
@RestController
@RequestMapping("/canteen")
public class CanteenController {
    @Autowired
    private CanteenService canteenService;

    @ApiOperation(value = "获取食堂列表(分页)")
    @GetMapping("/page")
    public Resp<Pagination<CanteenVo>> page(@ApiParam(value = "分页参数") PageQueryParam param) {
        PageInfo<CanteenVo> pageInfo = canteenService.pageList(param);
        return Resp.successPageable(pageInfo);
    }

    @ApiOperation("根据食堂ID查询食堂详情")
    @GetMapping("/{id}")
    public Resp<CanteenVo> getCanteenById(@PathVariable("id") Integer id) {
        CanteenVo canteenVo = canteenService.getCanteenById(id);
        return Resp.success(canteenVo);
    }
}
